//
//  CityData.m
//  BosidengIphone
//
//  Created by  on 12-1-6.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "CityData.h"
#import "AppDelegate.h"

@implementation CityData
@synthesize cityID;
@synthesize name;
@synthesize longitude;
@synthesize latitude;
@synthesize modifyDate;

- (id)init {
    if (self = [super init]) {
        ;
    }
    return self;
}

- (void)dealloc {
    [cityID release];
    [name release];
    [latitude release];
    [longitude release];
    [modifyDate release];
    [super dealloc];
}

- (void)setValue:(NSDictionary *)data {
    [super setValue:data];
    self.cityID = [data objectForKey:@"CityID"];
    self.name = [data objectForKey:@"Name"];
    self.latitude = [data objectForKey:@"Latitude"];
    self.longitude = [data objectForKey:@"Longitude"];
    self.modifyDate = [data objectForKey:@"ModifyDate"];
}

+ (id)getItemByID:(NSString *)uid {
    return [CityData findFirstByCriteria:[CityData getItemQueryString:@"city_i_d" value:uid]];
}

+ (NSArray *)getAllItems {
    NSString *query = [NSString stringWithFormat:@"WHERE language='%@' ORDER BY city_i_d", [AppDelegate getLanguage]];
    return [CityData findByCriteria:query];
}

@end
